import { INotificationHelper } from '@/core';
import { notification } from 'ant-design-vue';
import { createVNode } from 'vue';

export class NotificationHelper implements INotificationHelper {
	/**
	 * @description 单例变量声明
	 * @protected
	 * @static
	 * @type {NotificationHelper}
	 * @memberof AppFuncHelper
	 */
	protected static service: INotificationHelper;

	/**
	 * @description 获取实例
	 * @static
	 * @return {*}  {INotificationHelper}
	 * @memberof NotificationHelper
	 */
	static getInstance(): INotificationHelper {
		if (!this.service) {
			this.service = new NotificationHelper();
		}
		return this.service;
	}

	/**
	 * @description 成功提示
	 * @param {string} title 标题
	 * @param {string} message 内容
	 * @memberof NotificationHelper
	 */
	success(title: string, message: string): void {
		notification.success({
			message: title,
			description: () => createVNode('div', { innerHTML: message }),
		});
	}

	/**
	 * @description 信息提示
	 * @param {string} title 标题
	 * @param {string} message 内容
	 * @memberof NotificationHelper
	 */
	info(title: string, message: string): void {
		notification.info({
			message: title,
			description: () => createVNode('div', { innerHTML: message }),
		});
	}

	/**
	 * @description 警告提示
	 * @param {string} title 标题
	 * @param {string} message 内容
	 * @memberof NotificationHelper
	 */
	warning(title: string, message: string): void {
		notification.warning({
			message: title,
			description: () => createVNode('div', { innerHTML: message }),
		});
	}

	/**
	 * @description 错误提示
	 * @param {string} title 标题
	 * @param {string} message 内容
	 * @memberof NotificationHelper
	 */
	error(title: string, message: string): void {
		notification.error({
			message: title,
			description: () => createVNode('div', { innerHTML: message }),
		});
	}
}
